$(function () {
//    判断是否已经登录,sessionStorage.getItem("username");表示登录成功的标识
    let username = sessionStorage.getItem("username");
    let isLogin = username == null;//运算符优先级
    if (isLogin) {
        location.href = "/login.html";
    }
});

//公共方法
function myAjax(url, data, type) {
    let result = null;
    $.ajax({
        type: type,//对应的是
        url: url,//@WebServlet("/login")
        data: data,
        async: false,
        dataType: "json",//后台传递给前端的数据格式---json
        success: function (data) {//data是后台传递给前端的值
            console.log(data, 111);
            if (data.code==-1) {
                location.href = "/login.html";
            } else {
                result = data;
            }

        }
    });
    return result;
}
